<?php
require_once "Common/database.php";
require_once "Common/values.php";



$_POST[lognumber]='%';
#$_POST[operator]=$row['Operator'];
$_POST[assigned]=$user;
$_POST[requestor]='%';
$_POST[subject]='%';
$_POST[proirty]='%';
$_POST[status]='%';
$_POST[closed]='';
$_POST[project]='%';
$_POST[due]='%';
$_POST[line]='%';






switch ($_POST[closed])
{
case ("Closed");
$_POST[closed]='checked';
	break;
case ("Open");
$_POST[closed]='';
	break;
case ("");
$_POST[closed]='';
	break;
}
echo '<P><h3>'.$title.'</h3>';
echo '<center><table><tr>';
echo '<FORM action="index.php?m=h&p=hfilter&f=helpdesk" method="POST"><td style="border:0px solid ;" valign="top"><select name=select onchange="this.form.submit();"><option>My</option>';
genSelect();
echo '</select></td><td class="noborder"></form></td>';
echo '<FORM action="index.php?p=hsearch&f=helpesk" method="POST"><td style="border:0px solid;" valign="top">';
echo 'Log:<INPUT type="text" name="logsearch" size="10" maxlength="10"></td> ';
echo ' <td class="noborder"><INPUT type="image" src="img/go.gif">
</FORM></td>';
echo '</tr></table><center>';
require 'Common/dashboard2.php';
echo '<br>';
colourkey();


echo '<FORM action="index.php?m=h&p=hfilter&f=helpdesk" method="POST">';
echo '<TABLE width="100%" valign="top" Border=1 >';
echo '<tr bgcolor="'.$colourtoprow.'"><td>Log Number</td><td>Due
</td><td>Assigned to</td><td>Requestor</td><td>Subject</td><td>Proirty</td><td>Status</td><td>O/C</td></tr>';
echo '<tr><td><input type=text name=lognumber size="8" value='.$_POST[lognumber].'></td><td><INPUT type="text" size="8"name="due" value="'.$_POST[due].'">';
echo '</td>';
echo '<td><SELECT name="assigned">';
echo '<option>'.$_POST[assigned].'</option><option> </option>';
echo '<option>%</option>';
echo '<option>Not Assigned</option>';
genOperator();
echo '</select></td>';
echo '<td><input type=text name=requestor value='.$_POST[requestor].'>';
echo ' </td><td><input type=text name=subject size="70" value="'.$_POST[subject].'"></td><td><select name=proirty><option>'.$_POST[proirty].'</option>';
echo '<option></option>';
echo '<option>%</option>';
genProirty();
echo '</td>';
echo '<INPUT type="hidden" name="line"><td><select name=status><option>'.$_POST[status].'</option><option></option><option>%</option>';
genStatus();
echo '</td><td><select name="closed">';
if($_POST[closed]=='checked')
{
$_POST[closed]='Closed';
}
else
{
if($_POST[closed]=='%')
{
$_POST[closed]='All (%)';
}
else 
{
$_POST[closed]='Open';
}
}
echo '<option>'.$_POST[closed].'</option><option></option>';
echo '<option>Open</option><option>Closed</option><option>%</option></td>';
echo '</td><td><INPUT type="submit" value="Go"></td></tr>';
$result = mysql_query("SELECT * FROM tblJobs WHERE line='3' AND Closed!='checked' AND Assigned LIKE '$user'");

echo '<tr><td colspan="2"> On Hold </td><td colspan="7"><b>',mysql_affected_rows(),' Records found</td></tr>';

while($row = mysql_fetch_array($result))
  {
   if($row[Closed]=='checked')
{
$row[Closed]='Closed';
}
else
{
$row[Closed]='Open';
}
  echo '
<tr ';
colourjobs();
echo 'id="row'.$i.'" onMouseOver="row'.$i.'.style.backgroundColor=\''.$colourselector.'\';" onmouseout="row'.$i.'.style.backgroundColor=\''.$colour.'\';" onclick="location.href=\'index.php?f=helpdesk&p=hupdate&log='.$row['LogNumber'] .' \'">
<td class="jobstable">'.$row['LogNumber']. '</td><td class="jobstable">' . $row['Due'].'</td>'.'<td class="jobstable">'.$row[Assigned].'</td><td class="jobstable">'.$row['Requestor'].'</td><td class="jobstable">'.$row[Subject].'</td>'.'<td class="jobstable">'.$row[Proirty].'</td>'.'<td class="jobstable">'.$row[Status].'</td>'.'<td class="jobstable">'.$row[Closed].'</td></tr>';
  $i=$i+1;
  }
$result = mysql_query("SELECT * FROM tblJobs WHERE line LIKE '1' AND Closed!='checked' AND Assigned LIKE '$user'");

echo '<tr><td colspan="2"> 1st Line </td><td colspan="7"><b>',mysql_affected_rows(),' Records found</td></tr>';

while($row = mysql_fetch_array($result))
  {
   if($row[Closed]=='checked')
{
$row[Closed]='Closed';
}
else
{
$row[Closed]='Open';
}
  echo '
<tr ';
colourjobs();
echo 'id="row'.$i.'" onMouseOver="row'.$i.'.style.backgroundColor=\''.$colourselector.'\';" onmouseout="row'.$i.'.style.backgroundColor=\''.$colour.'\';" onclick="location.href=\'index.php?f=helpdesk&p=hupdate&log='.$row['LogNumber'] .' \'">
<td class="jobstable">'.$row['LogNumber']. '</td><td class="jobstable">' . $row['Due'].'</td>'.'<td class="jobstable">'.$row[Assigned].'</td><td class="jobstable">'.$row['Requestor'].'</td><td class="jobstable">'.$row[Subject].'</td>'.'<td class="jobstable">'.$row[Proirty].'</td>'.'<td class="jobstable">'.$row[Status].'</td>'.'<td class="jobstable">'.$row[Closed].'</td></tr>';
  $i=$i+1;
  }

  $result = mysql_query("SELECT * FROM tblJobs WHERE line LIKE '2' AND Closed!='checked' AND Assigned LIKE '$user'");

echo '<tr><td colspan="2"> 2nd Line </td><td colspan="7"><b>',mysql_affected_rows(),' Records found</td></tr>';

while($row = mysql_fetch_array($result))
  {
   if($row[Closed]=='checked')
{
$row[Closed]='Closed';
}
else
{
$row[Closed]='Open';
}
  echo '
<tr ';
colourjobs();
echo 'id="row'.$i.'" onMouseOver="row'.$i.'.style.backgroundColor=\''.$colourselector.'\'" onmouseout="row'.$i.'.style.backgroundColor=\''.$colour.'\';" onclick="location.href=\'index.php?f=helpdesk&p=hupdate&log='.$row['LogNumber'] .' \'">
<td class="jobstable">'.$row['LogNumber']. '</td><td class="jobstable">' . $row['Due'].'</td>'.'<td class="jobstable">'.$row[Assigned].'</td><td class="jobstable">'.$row['Requestor'].'</td><td class="jobstable">'.$row[Subject].'</td>'.'<td class="jobstable">'.$row[Proirty].'</td><td class="jobstable">'.$row[Status].'</td>'.'<td class="jobstable">'.$row[Closed].'</td></tr>';
  $i=$i+1;
  }

  

#echo '</table><p>Not assigned<p><table width=100%>';
#echo '<tr><td width=8></td></tr>';
  $result = mysql_query("SELECT * FROM tblJobs WHERE Assigned='Not assigned' AND Closed!='checked' AND Status!='Delete job'");

echo '<tr><td colspan="2"> Not assigned </td><td colspan="7"><b>',mysql_affected_rows(),' Records found</td></tr>';
  while($row = mysql_fetch_array($result))
  {
   if($row[Closed]=='checked')
{
$row[Closed]='Closed';
}
else
{
$row[Closed]='Open';
}
  echo '
<tr ';
colourjobs();
echo 'id="row'.$i.'" onMouseOver="row'.$i.'.style.backgroundColor=\''.$colourselector.'\';" onmouseout="row'.$i.'.style.backgroundColor=\''.$colour.'\';" onclick="location.href=\'index.php?f=helpdesk&p=hupdate&log='.$row['LogNumber'] .' \'">
<td class="jobstable">'.$row['LogNumber']. '</td><td class="jobstable">' . $row['Due'].'</td>'.'<td class="jobstable">'.$row[Assigned].'</td><td class="jobstable">'.$row['Requestor'].'</td><td class="jobstable">'.$row[Subject].'</td>'.'<td class="jobstable">'.$row[Proirty].'</td><td class="jobstable">'.$row[Status].'</td>'.'<td class="jobstable">'.$row[Closed].'</td></tr>';
  $i=$i+1;
  }

  

echo '</TABLE> </FORM>';
mysql_close();
?>